package aigcAdminUtils

import "gitee.com/wchpub/goComfyuiApi"

// agent通信协议

// agentApi返回的基本消息结构体
type AgentRespBase struct {
	ErrorCode int    `json:"errorCode"`
	Message   string `json:"message"`
}

// agentApi请求的基本消息结构体
type AgentReqBase struct {
}

type AgentGetWorkflowProgressRespItem struct {
	Status   AgentTaskStatus `json:"status"`   //状态
	Progress float64         `json:"progress"` //进度值 1代表 100%
}

// 获取工作流进度协议
type AgentGetWorkflowProgressResp struct {
	AgentRespBase
	Tasks map[string]*AgentGetWorkflowProgressRespItem `json:"tasks"`
}
type AgentGetWorkflowProgressReq struct {
	AgentReqBase
	TaskId []string `json:"taskId"`
}

// 获取工作流输出协议
type AgentGetWorkflowOutputsResp struct {
	AgentRespBase
	Images []goComfyuiApi.OutputImageInfo `json:"imageInfo,omitempty"`
	Texts  []string                       `json:"texts,omitempty"`
}
type AgentGetWorkflowOutputsReq struct {
	AgentReqBase
	TaskId  string             `json:"taskId"`
	OutType WorkflowOutputType `json:"outType"`
}

type AgentDownloadWorkflowImageResp struct {
	AgentRespBase
	ImageBody []byte `json:"imageBody"`
}
type AgentDownloadWorkflowImageReq struct {
	AgentReqBase
	Filename  string `json:"filename"`
	Subfolder string `json:"subfolder"`
}

type AgentExecuteWorkflowResp struct {
	AgentRespBase
	TaskId string `json:"taskId"`
	//PromptID string `json:"promptID"`
}
type AgentExecuteWorkflowReq struct {
	AgentReqBase
	WorkflowId  string                       `json:"workflowId"`  //工作流id
	WorkflowDoc goComfyuiApi.WorkflowFmt     `json:"workflowDoc"` //工作流执行时的api快照
	Params      []goComfyuiApi.WorkflowParam `json:"params"`      //工作流参数
}

// 已废弃
type AgentGetWorkflowImagesResp struct {
	AgentRespBase
	Images []goComfyuiApi.OutputImageInfo `json:"imageInfo"`
}
type AgentGetWorkflowImagesReq struct {
	AgentReqBase
	TaskId string `json:"taskId"`
}

type AgentInterruptWorkflowResp struct {
	AgentRespBase
}
type AgentInterruptWorkflowReq struct {
	AgentReqBase
	//PromptID string `json:"promptID"`
	TaskId string `json:"taskId"`
}

type AgentTaskStatus int

const (
	AgentTaskStatus_Success     AgentTaskStatus = 0 //已成功
	AgentTaskStatus_NotStart    AgentTaskStatus = 1 //排队中
	AgentTaskStatus_Executing   AgentTaskStatus = 2 //执行中
	AgentTaskStatus_NotFound    AgentTaskStatus = 3 //任务不存在
	AgentTaskStatus_Interrupted AgentTaskStatus = 4 //已中断
	AgentTaskStatus_Error       AgentTaskStatus = 5 //执行过程中发生了错误

)

type AgentTaskStatusResp struct {
	AgentRespBase
	Status   AgentTaskStatus `json:"status"`
	Progress float64         `json:"progress"` //进度[0,1] 如果状态为配对中，值代表等待的人数
}
type AgentTaskStatusReq struct {
	AgentReqBase
	TaskId string `json:"taskId"`
}

type AgentUploadImageResp struct {
	AgentRespBase
	FileName string `json:"fileName"`
}
type AgentUploadImageReq struct {
	AgentReqBase
	ImageData []byte `json:"imageData"`
	ImageName string `json:"imageName"`
}
